﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Newtonsoft.Json;

namespace SlickGridNet.Utils
{
	static class JsonExtensions
	{
		/// <summary>
		/// Set formatting options depending on <paramref name="formatOutput"/> parameter value.
		/// </summary>
		/// <param name="jtw"><see cref="JsonTextWriter"/> instance.</param>
		/// <param name="formatOutput">If <c>True</c> set options for formatting output of serialization.</param>
		/// <returns></returns>
		public static JsonTextWriter SetFormatting(this JsonTextWriter jtw, bool formatOutput)
		{
			if (formatOutput)
			{
				jtw.Formatting = Formatting.Indented;
				jtw.IndentChar = '\t';
				jtw.Indentation = 1;
			}
			return jtw;
		}
	}
}
